home *** CD-ROM | disk | FTP | other *** search
/ MPEG Toolkit / MPEG Toolkit.iso / dos / display / drvsrc / ati.asm < prev    next >
Encoding:
Assembly Source File  |  1997-01-01  |  7.3 KB  |  275 lines

  1. ; This is file ATIVGA.ASM
  2.  
  3. ;
  4.  
  5. ; Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  6.  
  7. ;
  8.  
  9. ; This file is distributed under the terms listed in the document
  10.  
  11. ; "copying.dj", available from DJ Delorie at the address above.
  12.  
  13. ; A copy of "copying.dj" should accompany this file; if not, a copy
  14.  
  15. ; should be available from where this file was obtained.  This file
  16.  
  17. ; may not be distributed without a verbatim copy of "copying.dj".
  18.  
  19. ;
  20.  
  21. ; This file is distributed WITHOUT ANY WARRANTY; without even the implied
  22.  
  23. ; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  24.  
  25. ;
  26.  
  27. ;
  28.  
  29. ; Modify for the ATI VGA WONDER
  30.  
  31. ; by Luc Bussieres, bussiere@dmi.usherb.ca
  32.  
  33. ; University of Sherbrooke
  34.  
  35. ; March 9th, 1991
  36.  
  37. ;
  38.  
  39. ; Version revised by Patrick Daloze, daloze@iro.umontreal.ca
  40.  
  41. ; University of Montreal
  42.  
  43. ; Juilly, 4th, 1991
  44.  
  45. ;
  46.  
  47.  
  48.  
  49. cseg    segment byte public 'code'
  50.  
  51.         assume  cs:cseg, ds:cseg, es:cseg, ss:nothing
  52.  
  53.         .386
  54.  
  55.  
  56.  
  57.         dw      offset init_routine
  58.  
  59.         dw      offset paging_routine
  60.  
  61.         dw      1       ; set to 1 if separate read & write windows or
  62.  
  63.                         ; only 64K of video RAM (ie: no paging)
  64.  
  65.  
  66.  
  67. def_tw  dw      80      ; filled in by go32 if GO32 env. var. is set
  68.  
  69. def_th  dw      25
  70.  
  71. def_gw  dw      640
  72.  
  73. def_gh  dw      480
  74.  
  75. IO_Add  dw      0
  76.  
  77.  
  78.  
  79. ;--------------------------------------------------------------------------
  80.  
  81. ; Entry: AX=mode selection
  82.  
  83. ;               0=80x25 text
  84.  
  85. ;               1=default text
  86.  
  87. ;               2=text CX cols by DX rows
  88.  
  89. ;               3=biggest text
  90.  
  91. ;               4=320x200 graphics
  92.  
  93. ;               5=default graphics
  94.  
  95. ;               6=graphics CX width by DX height
  96.  
  97. ;               7=biggest non-interlaced graphics
  98.  
  99. ;               8=biggest graphics
  100.  
  101. ;
  102.  
  103. ; NOTE: This runs in real mode, but don't mess with the segment registers.
  104.  
  105. ;       For mode 5 to 8 (640x480 or over): only for ATI Version 2 or more
  106.  
  107. ;       (separate read and write planing).
  108.  
  109. ;
  110.  
  111. ; Exit:  CX=width (in pixels or characters)
  112.  
  113. ;        DX=height
  114.  
  115.  
  116.  
  117. init_table      label   word
  118.  
  119.         dw      offset init_0
  120.  
  121.         dw      offset init_1
  122.  
  123.         dw      offset init_2
  124.  
  125.         dw      offset init_3
  126.  
  127.         dw      offset init_4
  128.  
  129.         dw      offset init_5
  130.  
  131.         dw      offset init_6
  132.  
  133.         dw      offset init_7
  134.  
  135.         dw      offset init_8
  136.  
  137.  
  138.  
  139. init_routine    proc    far
  140.  
  141.         cmp     ax,8
  142.  
  143.         jbe     valid_req
  144.  
  145.         ret
  146.  
  147. valid_req:
  148.  
  149.         shl     ax,1
  150.  
  151.         mov     bx,ax
  152.  
  153.         jmp     init_table[bx]
  154.  
  155.  
  156.  
  157. init_0: ; 80x25 text
  158.  
  159.         mov     ax,3
  160.  
  161.         int     10h
  162.  
  163.         mov     cx,80
  164.  
  165.         mov     dx,25
  166.  
  167.         ret
  168.  
  169.  
  170.  
  171. init_1: ; default text
  172.  
  173.         mov     cx,def_tw
  174.  
  175.         mov     dx,def_th
  176.  
  177.         jmp     init_2
  178.  
  179.  
  180.  
  181. init_2_table    label   word
  182.  
  183.         dw      01h, 40, 25
  184.  
  185.         dw      03h, 80, 25
  186.  
  187.         dw      23h, 132, 25
  188.  
  189.         dw      33h, 132, 44
  190.  
  191. init_2_tend     label   word
  192.  
  193.  
  194.  
  195. init_2: ; CX*DX text
  196.  
  197.         mov     si,offset init_2_table
  198.  
  199. init_2a:
  200.  
  201.         cmp     [si+2],cx
  202.  
  203.         jb      init_2b
  204.  
  205.         cmp     [si+4],dx
  206.  
  207.         jb      init_2b
  208.  
  209.         ; got a big enough one!
  210.  
  211.         jmp     init_2c
  212.  
  213. init_2b:
  214.  
  215.         cmp     si,offset init_2_tend - 6
  216.  
  217.         je      init_2c
  218.  
  219.         add     si,6
  220.  
  221.         jmp     init_2a
  222.  
  223. init_2c:
  224.  
  225.         mov     ax,[si]
  226.  
  227.         push    si
  228.  
  229.         int     10h
  230.  
  231.         pop     si
  232.  
  233.         mov     cx,[si+2]
  234.  
  235.         mov     dx,[si+4]
  236.  
  237.         ret
  238.  
  239.  
  240.  
  241. init_3: ; biggest text
  242.  
  243.         mov     ax,[init_2_tend-6]
  244.  
  245.         int     10h
  246.  
  247.         mov     cx,[init_2_tend-4]
  248.  
  249.         mov     dx,[init_2_tend-2]
  250.  
  251.         ret
  252.  
  253.  
  254.  
  255. init_4: ; 320x200 graphics
  256.  
  257.         mov     ax,13h
  258.  
  259.         int     10h
  260.  
  261.         mov     cx,320
  262.  
  263.         mov     dx,200
  264.  
  265.         ret
  266.  
  267.  
  268.  
  269. init_5: ; default graphics - should be 640x480 if supported
  270.  
  271.         mov     cx,def_gw
  272.  
  273.         mov     dx,def_gh
  274.  
  275.         jmp     init_6
  276.  
  277.  
  278.  
  279. init_6_table    label   word
  280.  
  281.         dw      13h, 320, 200
  282.  
  283.         dw      61h, 640, 400
  284.  
  285.         dw      62h, 640, 480
  286.  
  287.         dw      63h, 800, 600
  288.  
  289.         dw      64h, 1024, 768
  290.  
  291. init_6_tend     label   word
  292.  
  293.  
  294.  
  295. init_6: ; CX*DX graphics
  296.  
  297.         mov     si,offset init_6_table
  298.  
  299. init_6a:
  300.  
  301.         cmp     [si+2],cx
  302.  
  303.         jb      init_6b
  304.  
  305.         cmp     [si+4],dx
  306.  
  307.         jb      init_6b
  308.  
  309.         ; got a big enough one!
  310.  
  311.         jmp     init_6c
  312.  
  313. init_6b:
  314.  
  315.         cmp     si,offset init_6_tend - 6
  316.  
  317.         je      init_6c
  318.  
  319.         add     si,6
  320.  
  321.         jmp     init_6a
  322.  
  323. init_6c:
  324.  
  325.         mov     ax,[si]
  326.  
  327.         push    si
  328.  
  329.         int     10h
  330.  
  331.         pop     si
  332.  
  333.         mov     cx,[si+2]
  334.  
  335.         mov     dx,[si+4]
  336.  
  337.  
  338.  
  339.         push    ax
  340.  
  341.         push    dx
  342.  
  343.         mov     dx,01ceh   ; ATI register : ensure that separed R/W is enable
  344.  
  345.         mov     al,0beh    ; Register 2
  346.  
  347.         out     dx,al
  348.  
  349.         inc     dx
  350.  
  351.         in      al,dx
  352.  
  353.         dec     dx
  354.  
  355.         mov     ah,al
  356.  
  357.         or      ah,008h    ; set R/W enable
  358.  
  359.         mov     al,0beh
  360.  
  361.         out     dx,ax
  362.  
  363.         pop     dx
  364.  
  365.         pop     ax
  366.  
  367.  
  368.  
  369.         ret
  370.  
  371.  
  372.  
  373. init_7: ; biggest non-interlaced graphics
  374.  
  375.         mov     ax,63h
  376.  
  377.         int     10h
  378.  
  379.         mov     cx,800
  380.  
  381.         mov     dx,600
  382.  
  383.  
  384.  
  385.         push    ax
  386.  
  387.         push    dx
  388.  
  389.         mov     dx,01ceh   ; ATI register : ensure that separed R/W is enable
  390.  
  391.         mov     al,0beh    ; Register 2
  392.  
  393.         out     dx,al
  394.  
  395.         inc     dx
  396.  
  397.         in      al,dx
  398.  
  399.         dec     dx
  400.  
  401.         mov     ah,al
  402.  
  403.         or      ah,008h    ; set R/W enable
  404.  
  405.         mov     al,0beh
  406.  
  407.         out     dx,ax
  408.  
  409.         pop     dx
  410.  
  411.         pop     ax
  412.  
  413.  
  414.  
  415.         ret
  416.  
  417.  
  418.  
  419. init_8: ; biggest graphics
  420.  
  421.         mov     ax,63h
  422.  
  423.         int     10h
  424.  
  425.         mov     cx,800
  426.  
  427.         mov     dx,600
  428.  
  429.  
  430.  
  431.         push    ax
  432.  
  433.         push    dx
  434.  
  435.         mov     dx,01ceh   ; ATI register : ensure that separed R/W is enable
  436.  
  437.         mov     al,0beh    ; Register 2
  438.  
  439.         out     dx,al
  440.  
  441.         inc     dx
  442.  
  443.         in      al,dx
  444.  
  445.         dec     dx
  446.  
  447.         mov     ah,al
  448.  
  449.         or      ah,008h    ; set R/W enable
  450.  
  451.         mov     al,0beh
  452.  
  453.         out     dx,ax
  454.  
  455.         pop     dx
  456.  
  457.         pop     ax
  458.  
  459.  
  460.  
  461.         ret
  462.  
  463.  
  464.  
  465. init_routine    endp
  466.  
  467.  
  468.  
  469. ;--------------------------------------------------------------------------
  470.  
  471. ; Entry: AH=read page
  472.  
  473. ;        AL=write page
  474.  
  475. ;
  476.  
  477. ; NOTE: This runs in protected mode!  Don't mess with the segment registers!
  478.  
  479. ; This code must be relocatable and may not reference any data!
  480.  
  481. ;
  482.  
  483. ; Exit: VGA configured.
  484.  
  485. ;       AX,BX,CX,DX,SI,DI may be trashed
  486.  
  487. ;
  488.  
  489. ; Source: Advanced Programmer's Guide To SuperVGAs
  490.  
  491. ;
  492.  
  493.  
  494.  
  495.         assume  ds:nothing, es:nothing
  496.  
  497.  
  498.  
  499. paging_routine  proc    FAR
  500.  
  501.  
  502.  
  503.         mov     bx, ax
  504.  
  505.         and     ah,07h          ; Read-plane on bits 7-6-5
  506.  
  507.         ror     ah,1
  508.  
  509.         ror     ah,1
  510.  
  511.         ror     ah,1
  512.  
  513.         and     bh, 08
  514.  
  515.         shr     bh, 3
  516.  
  517.  
  518.  
  519.         and     al,0Fh          ; Write-plane on bits 3-2-1
  520.  
  521.         shl     al,1
  522.  
  523.         
  524.  
  525.  
  526.  
  527.         or      ah,al           ; Combine Read and Write plane
  528.  
  529.         or      ah, bh
  530.  
  531.  
  532.  
  533.         mov     dx,01ceh        ; ATI register
  534.  
  535.         mov     al,0b2h         ; plane select
  536.  
  537.         out     dx,ax
  538.  
  539.         ret
  540.  
  541. paging_routine  endp
  542.  
  543.  
  544.  
  545. cseg    ends
  546.  
  547.         end
  548.  
  549.